<%@page import="java.sql.*" %>
<%@ page import="java.util.*"%>
<%@ page import="com.hline.kbcss.MyDriver"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>::KBCSS::</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="styles.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="mainbg">
<!-- header begins -->
<%String uname=(String)session.getAttribute("uname");
String userid=(String)session.getAttribute("userid");
%>

<div id="header">
	<div id="buttons">
		<div class="menu_width">
		<ul>
			<li><a class="active">Welcome&nbsp;&nbsp;<%=uname%></a></li>
			<li><a href="logout.jsp" title="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Logout</a></li>
		</ul>
		</div>
	</div>
	<div id="logo">
		<a href="#">Knowledge Based Community Sharing System</a>
		<h5>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--Interaction With Industry<br /></h5>
	</div>
<!-- header ends -->
<!-- content begins -->
<div id="main"><div id="main_top"></div>
<div id="content_bg">
  <div id="content"></div>
  <div id="right"> </br>
    <h2>My Account</h2>
    <div class="categories">
      <ul>
        <li><a href="articles.jsp">Articles</a></li>        
        <li><a href="mat.jsp">Materials</a></li>
        <li><a href="res.jsp">Research papers</a></li>
        <li><a href="postma.jsp">Post Material/Research papers</a></li>
        <li><a href="postarticle.jsp">Post Articles</a></li>
        <li><a href="reports.jsp">Reports</a></li>
        <li><a href="cp.jsp">Change Password</a></li>
      </ul>
    </div>
  </div>
  <div class="rrr">
    <div class="spaa">
      <%
						 String name="";
						 String date="";
						 String usrname="";
						 String likes="";
						Statement st21=MyDriver.getConnection("READ");
						 ResultSet rs21=st21.executeQuery("select field from hr where userid='"+userid+"'");
						if(rs21.next()) {
						  if(rs21.getString(1)!=null && !rs21.getString(1).equals("")) {
						  StringTokenizer stringTokenizer = new StringTokenizer(rs21.getString(1),",");
							Statement st12=MyDriver.getConnection("READ");
							 while(stringTokenizer.hasMoreTokens()){
							 	likes = likes + "'"+stringTokenizer.nextElement() +"',";
							 }
							 likes=likes+"''";
						  }
						}
						Statement st12=MyDriver.getConnection("READ");	 
						 ResultSet rs12=st12.executeQuery("select * from articles where field in ("+likes+") order by field, postedon");
						while(rs12.next())
						  {
						 name=rs12.getString("title");	
						 date=rs12.getString("postedon");
						 int artid=rs12.getInt("aid");
						 String uid=rs12.getString("userid");
						  
			  
			  %>
			  
      <table width="97%" cellpadding="4"  >     
       
        <tr>
          <td align="left" valign="top">&nbsp;</td>
          <td align="left" valign="top"><strong>Article Posted By :</strong></td>
          <td align="left" valign="top"><div align="right">
            <div class="iiii">
            <%
            Statement st1=MyDriver.getConnection("READ");
						 	int uid1=Integer.parseInt(uid);
              ResultSet rs1=null;
			   if(uid1<1000)
			   {            
						 rs1=st1.executeQuery("select uname from user where userid='"+uid+"'");						
			   }
			   else if(uid1>1000&&uid1<10000)
			   {
				  rs1=st1.executeQuery("select uname from faculty where userid='"+uid+"'");
						
			   }
			   else
			   {
				   rs1=st1.executeQuery("select uname from hr where userid='"+uid+"'");
			   }
						if(rs1.next())
						  {
							usrname=rs1.getString("uname");%>
             <div align="left"><%=rs1.getString("uname")%> - [<%=((rs12.getInt("userid")<1000)?"USER":(rs12.getInt("userid")>1000 && rs12.getInt("userid")<10000)?"FACULTY":(rs12.getInt("userid")>10000)?"HR":"")%>]</div>
             			<%}%>
            </div>
            <div class="iiiii"><strong>Posted On :</strong><%=date%></div>
          </div></td>
        </tr>
        <tr>
          <td align="left" valign="top">&nbsp;</td>
          <td height="86" align="left" valign="top"><div class="dataartcile">
            <p><strong><%=name%></strong></p>
          </div></td>
          <td align="left" valign="top"><div class="dataartcile">
            <p><strong><%=rs12.getString("content")%></strong></p>
          </div></td>
        </tr>
        <tr>
          <td align="left" valign="top">&nbsp;</td>
          <td height="81" align="left" valign="top" colspan="2">
          <table width="460" border="0">
            <tr>
			<% if(uname.equals(usrname))
							  { }
						else
							  {%>
              <td><a href="like.jsp?id=<%=rs12.getInt(1)%>&tn=articles&tid=aid&value=like1&fn=articles.jsp"><img src="images/like.png" alt="like" /></a></td>
              <td><a href="like.jsp?id=<%=rs12.getInt(1)%>&tn=articles&value=unlike&amp;tid=aid&fn=articles.jsp"><img src="images/unlike.png" alt="like" /></a></td>
			  <tr><td><a href="report.jsp?id=<%=uid1 %>&fn=articles.jsp"><img src="images/report.png" alt="report article" /></a></td></tr>
			  <%}%>
              <td><img src="images/likeb.png" alt="like" width="24" height="21" /><strong> <%=rs12.getString("like1")%></strong></td>
              <td><img src="images/dis.png".jpg" alt="like" width="24" height="21" /><strong> <%=rs12.getString("unlike")%></strong></td>
              <td><a href="artcomment.jsp?aid=<%=rs12.getInt("aid")%>&title=<%=name%>"><font color="#FFFFFF">Comment</font></a></td>
              <td>&nbsp;</td>
            </tr>
          </table>------------------------------
            <p><font color="red">Comments on this article :</font></p>
            <p>&nbsp;</p>
<p>
  <%String cuname="";
		Statement st=MyDriver.getConnection("READ");
		ResultSet rs=st.executeQuery("select * from comments where aid="+artid+"");
		while(rs.next())
		{	
			String comment=rs.getString("comment");
			String usrid=rs.getString("uid");
			 
			  %>
			  
<table width="97%" cellpadding="4"  >          
        <tr>
          <td align="left" valign="top">&nbsp;</td>
          <td align="left" valign="top"><strong>Comment From :</strong></td>
          <td align="left" valign="top">
          <div align="right">
            <div class="iiii">
            <%
            Statement st2=MyDriver.getConnection("READ");
							int uid2=Integer.parseInt(usrid);
              ResultSet rs2=null;
			   if(uid2<1000)
			   {            
						 rs2=st2.executeQuery("select uname from user where userid='"+uid2+"'");						
			   }
			   else if(uid2>1000&&uid2<10000)
			   {
				  rs2=st2.executeQuery("select uname from faculty where userid='"+uid2+"'");
			   }
			   else
			   {
				   rs2=st2.executeQuery("select uname from hr where userid='"+uid2+"'");
			   }
						while(rs2.next())
						  {
							cuname=rs2.getString("uname");%>             
              <div align="left"><%=rs2.getString("uname")%></div><%}%>
            </div>            
          </div>
          </td>
        </tr>
        <tr> 
        <td align="left" valign="top">&nbsp;</td>
          <td height="63" align="left" valign="top"><div class="dataartcile">
            <p></p>
          </div></td>         
          <td align="left" valign="top">
          <div class="dataartcile">
            <p><strong><%=rs.getString("comment")%></strong></p>
          </div>
          </td>
        </tr>
        <tr>
          <td align="left" valign="top">&nbsp;</td>
          <td height="81" align="left" valign="top" colspan="2">
           <table width="460" border="0">
            <tr>
			<% if(uname.equals(cuname))
							  { }
						else
							  {%>
              <td><a href="like.jsp?id=<%=rs.getInt("luid")%>&tn=comments&tid=luid&value=like1&fn=articles.jsp"><img src="images/like.png" alt="like" /></a></td>
              <td><a href="like.jsp?id=<%=rs.getInt("luid")%>&tn=comments&value=unlike&tid=luid&fn=articles.jsp"><img src="images/unlike.png" alt="like" /></a></td>
			  <tr><td><a href="report.jsp?id=<%=uid2%>&fn=articles.jsp"><img src="images/reportc.png" alt="report this comment" /></a></td></tr>
			  <%}%>
              <td><img src="images/likeb.png" alt="like" width="24" height="21" /><strong> <%=rs.getString("like1")%></strong></td>
              <td><img src="images/dis.png".jpg" alt="like" width="24" height="21" /><strong> <%=rs.getString("unlike")%></strong></td>
              </tr>
          </table>   <%}%>  
          </td>      
        </tr>
      </table>
      </p></td>
 
        </tr>
      </table>=================================================================
      <%}
		 %>
    </div>
  </div>
</div>
</div>
</div>

<!-- content ends -->
<!-- footer begins -->
</td>
</tr>
</table>
</p>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>

<div id="footer">
  <p>Copyright  2011. Designed by <a href="#" title="Flash Templates">Knowledge Based Community Sharing System</a></p>
		<p><a href="#">Privacy Policy</a> | <a href="#">Terms of Use</a> 
</div>
<!-- footer ends -->

</div>

</body>
</html>
